﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenRasta.Web;
using OpenRasta.Configuration;
using uREST.Core.Resources;
using uREST.Core.Codecs;
using uREST.Core.Handlers;

namespace uREST.Core.Services
{
    public class TokenService : IuRESTService
    {
        public EndPoint EndPoint
        {
            get 
            {
                return new EndPoint
                {
                    Name = "Token Service",
                    Description = "Creates an authentication token for the given credentials",
                    Href = typeof(Token).CreateUri("Token").ToString()
                };
            }
        }

        public void RegisterHandlers()
        {
            ResourceSpace.Has.ResourcesOfType<Token>()
                .AtUri(uRESTConfig.BaseUrl + "/token").Named("Token")
                .HandledBy<TokenHandler>()
                .TranscodedBy<JsonNetCodec>();
        }
    }
}
